package com.systop.servlet;

import com.systop.entity.Message;
import com.systop.service.MessageService;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.ArrayList;

public class MessageListServlet extends HttpServlet {
    private MessageService messageService = new MessageService();

    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        ArrayList<Message> messageList = messageService.findAll();
        request.setAttribute("messageList",messageList);
        request.getRequestDispatcher("message/list.jsp").forward(request,response);
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

        doPost(request,response);
    }
}
